<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="https://xcximg.juseyun.com/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://xcximg.juseyun.com/assets/css/style.css" />
    <link href="https://xcximg.juseyun.com/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="https://xcximg.juseyun.com/assets/css/ace.min.css" />
    <link rel="stylesheet" href="https://xcximg.juseyun.com/assets/font/css/font-awesome.min.css" />
    <script src="https://xcximg.juseyun.com/assets/js/jquery-1.9.1.min.js"></script>
    <script src="https://xcximg.juseyun.com/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://xcximg.juseyun.com/assets/js/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="https://xcximg.juseyun.com/assets/js/typeahead-bs2.min.js"></script>
    <script src="https://xcximg.juseyun.com/assets/js/jquery.dataTables.min.js"></script>
    <script src="https://xcximg.juseyun.com/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="https://xcximg.juseyun.com/assets/layer/layer.js" type="text/javascript"></script>
    <script src="https://xcximg.juseyun.com/assets/js/lrtk.js" type="text/javascript"></script>
    <script src="https://xcximg.juseyun.com/assets/layer/layer.js" type="text/javascript"></script>
    <script src="https://xcximg.juseyun.com/assets/laydate/laydate.js" type="text/javascript"></script>
    <title>添加书本信息</title>
</head>
<style>
    .table_menu_list {
        width: 100% !important;
    }

    #add_administrator_style2 {
        margin: 15px
    }
</style>

<body>
    <div class="page-content clearfix">
        <div class="administrator">
            <div class="d_Confirm_Order_style">
                <div class="search_style">

                    <ul class="search_content clearfix">
                        <li>
                            <label class="l_f">类别名称</label>
                            <input name="" type="text" class="text_add" placeholder="" style=" width:400px" />
                        </li>
                        <li>
                            <label class="l_f">添加时间</label>
                            <input class="inline laydate-icon" id="start" style=" margin-left:10px;">
                        </li>
                        <li style="width:90px;">
                            <button type="button" class="btn_search">
                                <i class="fa fa-search"></i>查询</button>
                        </li>
                    </ul>
                </div>
                <!--操作-->
                <div class="border clearfix">
                    <span class="l_f">
                        <a href="javascript:ovid()" id="administrator_add" class="btn btn-warning">
                            <i class="fa fa-plus"></i> 添加类别</a>
                        <a href="javascript:ovid()" class="btn btn-danger">
                            <i class="fa fa-trash"></i> 批量删除</a>
                    </span>
                </div>
                <!--管理员列表-->

                
            </div>
        </div>
    </div>
    <!--添加图书-->
    <div id="add_administrator_style" class="add_menber" style="display:none">
        <form action="add_bookcalss" method="post" id="form-admin-add">
            <div class="form-group">
                <label class="form-label">
                    <span class="c-red">*</span>大类别：</label>
                <div class="formControls">
                    <input type="text" class="input-text" value="" placeholder="名称" id="user-name" name="big_class" datatype="*" nullmsg="请输入类别不能为空">
                </div>
                <div class="col-4">
                    <span class="Validform_checktip"></span>
                </div>
            </div>
            <div class="form-group">
                <label class="form-label">
                    <span class="c-red">*</span>小类别：</label>
                <div class="formControls">
                    <input type="text" placeholder="作者" name="small_class" autocomplete="off" value="" class="input-text" datatype="*" nullmsg="类别名称不能为空">
                </div>
                <div class="col-4">
                    <span class="Validform_checktip"></span>
                </div>
            </div>
            <div>
                <input class="btn btn-primary radius" type="submit" id="Add_Administrator" value="&nbsp;&nbsp;添加类别&nbsp;&nbsp;">
        </form>
        </div>
    </div>
</body>

</html>
<script type="text/javascript">
    jQuery(function ($) {
        var oTable1 = $('#sample_table').dataTable({
            "aaSorting": [
                [1, "desc"]
            ], //默认第几个排序
            "bStateSave": true, //状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {
                    "orderable": false,
                    "aTargets": [0, 2, 3, 4, 5, 7, 8,]
                } // 制定列不参与排序
            ]
        });
        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });

        $('[data-rel="tooltip"]').tooltip({
            placement: tooltip_placement
        });

        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    });

</script>
<script type="text/javascript">
    cities = new Object();
    cities['图书图库'] = new Array('小说作品', '人文社科', '品质生活', '文学作品', '计算机');
    cities['女生小说'] = new Array('都市言情', '穿越时空', '官斗宅斗', '古风古韵', '短篇美文');
    cities['男生小说'] = new Array('都市生活', '官场职场', '玄幻小说', '悬疑探险', '军事谍战', '科幻奇幻', '同人网游', '灵异恐怖', '历史科幻', '短篇小说');
    function set_city(province, city) {
        var pv, cv;
        var i, ii;
        pv = province.value;
        cv = city.value;
        city.length = 1;
        if (pv == '0') return;
        if (typeof (cities[pv]) == 'undefined') return;
        for (i = 0; i < cities[pv].length; i++) {
            ii = i + 1;
            city.options[ii] = new Option();
            city.options[ii].text = cities[pv][i];
            city.options[ii].value = cities[pv][i];
        }
    }
    $(function () {
        $("#administrator").fix({
            float: 'left',
            //minStatue : true,
            skin: 'green',
            durationTime: false,
            spacingw: 50, //设置隐藏时的距离
            spacingh: 270, //设置显示时间距
        });
    });
    //字数限制
    function checkLength(which) {
        var maxChars = 100; //
        if (which.value.length > maxChars) {
            layer.open({
                icon: 2,
                title: '提示框',
                content: '您输入的字数超过限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0, maxChars);
            return false;
        } else {
            var curr = maxChars - which.value.length; //250 减去 当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }
    };
    //初始化宽度、高度
    $(".widget-box").height($(window).height() - 215);
    $(".table_menu_list").width($(window).width() - 260);
    $(".table_menu_list").height($(window).height() - 215);
    //当文档窗口发生改变时 触发
    $(window).resize(function () {
        $(".widget-box").height($(window).height() - 215);
        $(".table_menu_list").width($(window).width() - 260);
        $(".table_menu_list").height($(window).height() - 215);
    })
    laydate({
        elem: '#start',
        event: 'focus'
    });

    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!', {
                icon: 5,
                time: 1000
            });
        });
    }
    /*用户-启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', {
                icon: 6,
                time: 1000
            });
        });
    }
    /*产品-编辑*/
    function member_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    /*产品-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {
                icon: 1,
                time: 1000
            });
            var id = $(obj).parents("tr").attr("data-id")
            $.ajax({
                type: "post",
                url: "Delete_Bookinfo",
                dataType: "json",
                timeout: 5000,
                data: {
                    "id": id,
                },
                async: true,
                success: function (res) {
                    console.log(res)
                },
                error: function (err) {
                    console.log(err)
                }
            });
        });


    }
    /*添加书库*/
    $('#administrator_add').on('click', function () {
        layer.open({
            type: 1,
            title: '添加书库',
            area: ['700px', ''],
            shadeClose: false,
            content: $('#add_administrator_style'),
        });
    })


    /*修改图书信息*/
    $('.bianji').on('click', function (e) {
        layer.open({
            type: 1,
            title: '修改图书信息',
            area: ['700px', ''],
            shadeClose: false,
            content: $('#add_administrator_style2'),
        });
        console.log($(this).attr("data-id"));
        var data_id = $(this).attr("data-id");
        var inputs = $("#add_administrator_style2").find("input");
        var textareas = $("#add_administrator_style2").find("textarea");
        //单本书的信息修改
        $.ajax({
            type: "post",
            url: "Book_oneifno",
            dataType: "json",
            timeout: 5000,
            data: {
                "data_id": data_id,
            },
            async: true,
            success: function (res) {
                if (res.success == 100) {
                    console.log(res.body)
                    inputs[0].value = res.body.book_name;
                    inputs[1].value = res.body.book_author;
                    inputs[2].value = res.body.price;
                    inputs[3].value = res.body.book_picurl;
                    inputs[4].value = res.body.book_url;
                    inputs[5].value = res.body.book_id;
                    textareas[0].value = res.body.book_profile;
                }
            },
            error: function (err) {
                console.log(err)
            }
        });

    })
    //表单验证提交
    $("#form-admin-add").Validform({
        tiptype: 2,
        callback: function (data) {
            //form[0].submit();
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: data.status,
                    time: 1000
                }, function () {
                    location.reload(); //刷新页面
                });
            } else {
                layer.msg(data.info, {
                    icon: data.status,
                    time: 3000
                });
            }
            var index = parent.$("#iframe").attr("src");
            parent.layer.close(index);
            //
        }

    });

</script>